package com.ccz.demo.design.chain;

import com.ccz.demo.design.chain.a.LevelOneFilter;
import com.ccz.demo.design.chain.a.LevelTwoFilter;

import java.util.ArrayList;
import java.util.List;

public class FilterFactory {
    static List<Filter> filterList = new ArrayList<>();
    static {

        filterList.add(new LevelTwoFilter());
        filterList.add(new LevelOneFilter());
    }

    public static List<Filter> getFilters(String packages) {

        // 通过注解扫描指定包



        return filterList;
    }


//    Reflections reflections = new Reflections(packages);
//    Set<Class<?>> filters = reflections.getTypesAnnotatedWith(EnableFilter.class);
//    // 如果该包下有被EnableFilter注释的类，则将类的示例添加到列表中并返回列表
//        filters.forEach(filter -> {
//        try {
//            filterList.add((Filter) filter.newInstance());
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
//    });

}
